package com.xo.common.until;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicInteger;

@Slf4j
public class idGenerateUntil {

    /**
     * 唯一租户id生成
     * 50 + 时间戳 + 3自增序列号
     */
    private static final AtomicInteger SEQUENCE = new AtomicInteger(0);

    public static Long generateTenantId() {
        long timestamp = System.currentTimeMillis();
        // 序列号：0-999循环，避免超过3位
        int sequence = SEQUENCE.incrementAndGet() % 1000;
        // 不足3位补0（确保长度一致）
        String sequenceStr = String.format("%03d", sequence);

        String tenantIdStr = "60" + timestamp + sequenceStr;
        return Long.parseLong(tenantIdStr);
    }


}
